package com.wzq.solution;

import java.util.HashMap;
import java.util.Map;

public class QmoveZeroes {
    public static  void moveZeroes(int[] nums) {


        int j=-1;


        for(int i=0;i<nums.length;i++){
            if(nums[i] == 0){
                if(j == -1){
                    j = i+1;
                }
                for(;j<nums.length;j++){
                    if(nums[j] != 0){
                        int tmp = nums[i];
                        nums[i] = nums[j];
                        nums[j] = tmp;
                        break;
                    }
                }
            }
        }

    }

    public static void main(String[] args) {
        int[] digits = new int[]{3,2,4};
        System.out.println(twoSum(digits,6));
        Map<Integer,Integer> m = new HashMap<Integer,Integer>();

    }

    public static int[] twoSum(int[] nums, int target) {
        Map<Integer,Integer> m = new HashMap<Integer,Integer>();

        int[] rst = new int[2];
        for(int i=0;i<nums.length;i++){
            if(m.containsKey(target-nums[i])){
                rst[0] = m.get(target-nums[i]);
                rst[1] = i;
                return rst;
            }
            m.put(nums[i],i);
        }
        return rst;
    }
}
